Python Docker

Docs


In [8]:
import sys
sys.version_info


Out[8]:
sys.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0)

In [11]:
import docker

In [12]:
client = docker.from_env()

In [18]:
myimages = client.images.list()

In [19]:
mycontainers = client.containers.list()

In [37]:
from json2html import *
from IPython.display import display, HTML, display_json
#HTML(json2html.convert(json = {'a':'2','b':'3'}))

In [48]:
htcss = """
    <style type="text/css">
    th {   background-color: yellow;}
    </style>
    """

for im in myimages:
    #client.images.list()
    #print(im.attrs)
    myhtml = HTML(json2html.convert(json = im.attrs))
    myhtml.data = myhtml.data + htcss
    #display(HTML(json2html.convert(json = im.attrs)))
    display(myhtml)
    #print(myhtml.data) 
    #display_json(json2html.convert(json = im.attrs))


VirtualSize46778681323
Idsha256:7a5ca9e9da01094448b74a5b8107411047234bcc8d366e0eea9e7686a1ad249d
Containers-1
Labels
Created1487576020
ParentIdsha256:f695faa7dcddb8e5481fc33a9ee3a418c1706eb90be9e65502667e1acc1be832
Size46778681323
RepoTags
  • mymod/ros:v1
RepoDigests
SharedSize-1
VirtualSize46778681323
Idsha256:f695faa7dcddb8e5481fc33a9ee3a418c1706eb90be9e65502667e1acc1be832
Containers-1
Labels
Created1487574410
ParentIdsha256:4c69df95ee82c82da7618b0d1217e3c9371389dd884cf115f351f364b2862fda
Size46778681323
RepoTags
  • ros:latest
RepoDigests
SharedSize-1
VirtualSize2279813345
Idsha256:d2b5faabb3cb87e6f5407883446976840b1ac78d85617ef3bdc1ac296d54e37b
Containers-1
Labels
Created1487564266
ParentIdsha256:41a925058bbe47334ff2b4ca142248de47a69beebf865d572231def372dd2ea5
Size2279813345
RepoTags
  • :
RepoDigests
  • @
SharedSize-1
VirtualSize2187223706
Idsha256:97682108ac3fc0cf92d1d07c4d5c9002ec6e84052edcc624b1db58ef071f3a44
Containers-1
Labels
Created1487312585
ParentIdsha256:dabcedefeb045409c16d9b0bd1be359ac60010416da4839a363b76cc57ab9009
Size2187223706
RepoTags
  • :
RepoDigests
  • @
SharedSize-1
VirtualSize1112478504
Idsha256:2a0f4b83ea3523f97378d967c3c3843ebe5a80efcbfd92bd8cb299a8eba19036
Containers-1
Labels
Created1487310924
ParentIdsha256:dabcedefeb045409c16d9b0bd1be359ac60010416da4839a363b76cc57ab9009
Size1112478504
RepoTags
  • :
RepoDigests
  • @
SharedSize-1
VirtualSize1112462560
Idsha256:6f1fbcf66d40d3c379d947f79ff31f6007765c36f59f2ceacb468db0d395d3bb
Containers-1
Labels
Created1487310393
ParentIdsha256:dabcedefeb045409c16d9b0bd1be359ac60010416da4839a363b76cc57ab9009
Size1112462560
RepoTags
  • :
RepoDigests
  • @
SharedSize-1
VirtualSize957674621
Idsha256:693eead3df4faacf0484481285f9903e1012d47c23244222ed9633be28344b90
Containers-1
Labels
Created1487307135
ParentIdsha256:af847bfdb7573953c20c587267c33f5eb0fc52021128680c5e4bd11dbc8dc59f
Size957674621
RepoTags
  • :
RepoDigests
  • @
SharedSize-1
VirtualSize1028771047
Idsha256:ea40dcc45724f3d77edd4fdf8cfd01047a2760ca8e83a7549da88a6d261b5d2a
Containers-1
Labels
Created1486857997
ParentId
Size1028771047
RepoTags
  • tensorflow/tensorflow:latest
RepoDigests
  • tensorflow/tensorflow@sha256:b93920e48c8c1727ce27c7b1bc310ba2b681deeca302a23f042586ac646e4881
SharedSize-1
VirtualSize957674601
Idsha256:af847bfdb7573953c20c587267c33f5eb0fc52021128680c5e4bd11dbc8dc59f
Containers-1
Labels
Created1485548361
ParentId
Size957674601
RepoTags
RepoDigests
  • ros@sha256:7f77d68741cc415df4b27bb7c4d143278cfe40c8e1b37f4a295203615e527198
SharedSize-1
VirtualSize183999476
Idsha256:84537c35b0b90babcf221d7bd44a43968e0cde61efb28acb107fca5ca1110098
Containers-1
Labels
Created1483387025
ParentIdsha256:68b8092a2c2414d896d752a5dbd5707d3c41ababa2c1918c171779406c663231
Size183999476
RepoTags
  • :
RepoDigests
  • @
SharedSize-1
VirtualSize89216812
Idsha256:1aa2b8b541baa2220d9dc4297236b0d5e9e2aa66a197dca2cc8a8d04fc122e6d
Containers-1
Labels
Created1473984777
ParentIdsha256:babf0db6bcb76ed09ced1ed7c970e3a0aa39dec7334b9e65c9ccf348f25659f0
Size89216812
RepoTags
  • gogs/gogs:latest
RepoDigests
SharedSize-1
VirtualSize120733278
Idsha256:82289c29817051a07f12402995559f05d0a576713349be9502f1f4d00109fb3d
Containers-1
Labels
Created1462317178
ParentIdsha256:16bfb1a1ed9b9c0003d341403acb3170ec753f9de602e973f6461a853423b414
Size120733278
RepoTags
  • ubuntu:latest
RepoDigests
SharedSize-1
VirtualSize967
Idsha256:919d9479e268095e169e40d1a6f830a0e67c56b0b20fd470fa9764e2997af666
Containers-1
Labels
Created1461714760
ParentIdsha256:63169caabf7a1c3ba02c58d4d7e9aab12d128c980a8969a5ce29a706bb9dbdd2
Size967
RepoTags
  • hello-world:latest
RepoDigests
SharedSize-1
VirtualSize3297179690
Idsha256:085194438f203e3db445b3448ee15ce155f775445ac9a97272729db4381d709e
Containers-1
Labels
Created1454295766
ParentIdsha256:5b65fbbeb0340c5ac85f802facba9df39989074d5a10265cabf88c8e9cd44481
Size3297179690
RepoTags
  • gibiansky/ihaskell:latest
RepoDigests
SharedSize-1

In [6]:
container = client.containers.get('24291d6ec7')

In [7]:
container.attrs['Config']['Image']


Out[7]:
'f695faa7dcdd'

In [8]:
container.logs()


Out[8]:
b''

In [9]:
container.stop()

In [17]:
#if len(client.nodes) > 0: client.nodes.list(filters={'role': 'manager'})
print(client.nodes)


<docker.models.nodes.NodeCollection object at 0x7fed801f35f8>

In [ ]: